async function chooseImage(obj={}){
  return new Promise((resolve,reject) => {
    let tmpobj = {
      success(res) {
        resolve(res)
      },
      fail(err) {
        reject(err)
      }
    };
    tmpobj = Object.assign(obj, tmpobj)
    wx.chooseImage(tmpobj)
  })
}

function saveImageToPhotosAlbum (filePath) {
  return new Promise((resolve,reject) => {
    wx.saveImageToPhotosAlbum({
      filePath: filePath,
      success(res) {
        resolve(res)
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

module.exports = {
  chooseImage: chooseImage,
  saveImageToPhotosAlbum: saveImageToPhotosAlbum
}